package com.wzy.designpattern.creational.prototype.clone;

import lombok.AllArgsConstructor;

import java.util.Date;

/**
 * 描述
 * 创建人    Wzy
 * 创建时间: 2020-05-15  20:34
 */

@AllArgsConstructor
public class Pig implements Cloneable {
    private String name;
    private Date birthday;

    @Override
    protected Object clone() throws CloneNotSupportedException {

        Pig pig = (Pig) super.clone();
        //深克隆 
        pig.birthday = (Date) pig.birthday.clone();
        return pig;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "Pig{" +
                "n  ame='" + name + '\'' +
                ", birthday=" + birthday +
                '}' + super.toString();
    }
}
